package com.itboye.textileexpes.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.MyOrderBeans;
import com.itboye.textileexpes.beans.OrderDeltilteBeans;
import com.itboye.textileexpes.interfaces.IMyOrder;
import com.itboye.textileexpes.json.ByJsonRequest.Builder;
import com.itboye.textileexpres.base.BaseErrorListener;
import com.itboye.textileexpres.base.BaseNetRepository;
import com.itboye.textileexpres.base.BaseSuccessReqListener;

public class MyOrderRepository extends BaseNetRepository implements IMyOrder<MyOrderBeans> {
	static final String MyOrder = "By_Order_query";
	static final String OrderDelety = "By_Order_detail";
	
	static final String Delete = "By_Order_cancel";
	//订单搜索
	static final String Saerch = "By_Order_query";
	

	public MyOrderRepository(ICompleteListener listener) {
		super(listener);
	}


	@Override
	public void add(MyOrderBeans model) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void delete(MyOrderBeans model) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void update(MyOrderBeans model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<MyOrderBeans>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid",model.getUid());
		map.put("keyword", model.getKeyword());
		map.put("page_index",model.getPage_index());
		map.put("page_size",model.getPage_size());

		(new Builder<MyOrderBeans>())
				.setTypeVerParamsAndReturnClass(MyOrder, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<MyOrderBeans>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}


	@Override
	public void getInfo(MyOrderBeans model) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<MyOrderBeans>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid",model.getUid());
		map.put("keyword", model.getKeyword());
		map.put("query_status", model.getQuery_status());
		map.put("page_index",model.getPage_index());
		map.put("page_size",model.getPage_size());

		(new Builder<MyOrderBeans>())
				.setTypeVerParamsAndReturnClass(MyOrder, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<MyOrderBeans>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}


	@Override
	public List<MyOrderBeans> query(MyOrderBeans model) {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public void getorder(String uid, String order_code) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<OrderDeltilteBeans>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid",uid);
		map.put("order_code",order_code);
		

		(new Builder<OrderDeltilteBeans>())
				.setTypeVerParamsAndReturnClass(OrderDelety, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<OrderDeltilteBeans>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}


	@Override
	public void getDelete(String uid, String order_code) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid",uid);
		map.put("order_code",order_code);

		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(Delete, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	

}
